<HTML>
<HEAD>
<TITLE>
BeanConfig.h
</TITLE>
</HEAD>
<BODY>
<PRE>
<font color="green">/*
* Copyright 2006 the original author or authors.
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*      http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</font>

<font color="blue">#ifndef</font> AUTUMN_BEANCONFIG_H
<font color="blue">#define</font> AUTUMN_BEANCONFIG_H

<font color="blue">#include</font> <font color="maroon">&#60;string&#62;</font>
<font color="blue">#include</font> <font color="maroon">&#60;vector&#62;</font>
<font color="blue">#include</font> <font color="maroon">"IBeanWrapper.h"</font>
<font color="blue">#include</font> <font color="maroon">"BeanProperty.h"</font>
<font color="blue">#include</font> <font color="maroon">"ValueWrapper.h"</font>
<font color="blue">#include</font> <font color="maroon">"AutumnDefinition.h"</font>

<font color="blue">using</font> <font color="blue">namespace</font> std;

<font color="blue">namespace</font> Autumn<font color="black">{</font>

<font color="blue">typedef</font> vector<font color="black">&#60;</font>BeanProperty<font color="black">*</font><font color="black">&#62;</font> PropertyList;
<font color="blue">typedef</font> IBeanWrapper<font color="black">*</font> WrapperMaker<font color="black">(</font><font color="black">)</font>;
<font color="blue">typedef</font> <font color="blue">void</font> WrapperFreer<font color="black">(</font>IBeanWrapper<font color="black">*</font><font color="black">)</font>;

<font color="green">/** 
 * Bean configuration.
 * @version 0.1.0
 * @since 2006-12-12
 */</font>
<font color="blue">class</font> BeanConfig<font color="black">{</font>
    
    <font color="green">/** Bean's name */</font>
    string Name;

    <font color="green">/** The function to create bean wrapper */</font>
    WrapperMaker <font color="black">*</font>WrapperCreater;

    <font color="green">/** The function to free bean wrapper */</font>
    WrapperFreer <font color="black">*</font>WrapperDeleter;
    
    <font color="green">/** Constructor's arguments */</font>
    PropertyList <font color="black">*</font>ConArgs;
    
    <font color="green">/** Depended objects, should be singleton. */</font>
    StrValueList DependedObjects;
    
    <font color="green">/** Bean's properties */</font>
    PropertyList <font color="black">*</font>Properties;

    <font color="green">/** Factory bean name*/</font>
    string FactoryBean;

    <font color="green">/**
     * Constructor method name. It may be bean's class name, bean's static 
     * factory method name or a factory's creating method name.
     */</font>
    string ConMethod;

    string InitMethod;
    string DestroyMethod;
    string DeleteMethod;

    <font color="green">/** Bean is singleton or not */</font>
    <font color="blue">bool</font> Singleton;

    <font color="green">/** Constructor arguments' types are got or not */</font>
    <font color="blue">bool</font> GotArgTypes;

<font color="blue">public</font><font color="black">:</font>
    <font color="green">/** Constructor */</font>
    BeanConfig<font color="black">(</font>TBean<font color="black">&</font> beandef, WrapperMaker<font color="black">*</font> wc, WrapperFreer<font color="black">*</font> wd<font color="black">)</font>;

    <font color="green">/** Destructor */</font>
    ~BeanConfig<font color="black">(</font><font color="black">)</font>;

    <font color="green">/** Create bean's wrapper */</font>
    IBeanWrapper<font color="black">*</font> createWrapper<font color="black">(</font><font color="black">)</font> <font color="blue">const</font>;
    
    <font color="green">/** 
     * Get constructor's arguments
     * @param pw The bean wrapper to get constructor arguments' types.
     */</font>
    PropertyList <font color="black">*</font>getConArgs<font color="black">(</font>IBeanWrapper<font color="black">*</font> pw<font color="black">)</font>;

    <font color="green">/** Get bean's properties */</font>
    PropertyList <font color="black">*</font>getProperties<font color="black">(</font><font color="black">)</font> <font color="blue">const</font><font color="black">{</font>
        <font color="blue">return</font> <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>Properties;
    <font color="black">}</font>

    <font color="green">/** Get depended objects list */</font>
    <font color="blue">const</font> StrValueList<font color="black">&</font> getDependedObjects<font color="black">(</font><font color="black">)</font> <font color="blue">const</font> <font color="black">{</font>
        <font color="blue">return</font> <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>DependedObjects;
    <font color="black">}</font>

    <font color="green">/** Get factory bean name */</font>
    string getFactoryBeanName<font color="black">(</font><font color="black">)</font> <font color="blue">const</font> <font color="black">{</font>
        <font color="blue">return</font> <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>FactoryBean;
    <font color="black">}</font>

    <font color="green">/** Get constructor method name */</font>
    string getConMethod<font color="black">(</font><font color="black">)</font> <font color="blue">const</font> <font color="black">{</font>
        <font color="blue">return</font> <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>ConMethod;
    <font color="black">}</font>

    <font color="green">/** Get status of being singleton or not */</font>
    <font color="blue">bool</font> isSingleton<font color="black">(</font><font color="black">)</font> <font color="blue">const</font> <font color="black">{</font><font color="blue">return</font> <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>Singleton;<font color="black">}</font>
<font color="black">}</font>;

<font color="black">}</font> <font color="green">// End namespace Autumn</font>
<font color="blue">#endif</font>

</PRE>
</BODY>
</HTML>
